<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var operation = prompt("欢迎使用计算机请输入符号\n1.加法\n2.减法\n3.乘法\n4除法");
        var one = parseFloat(prompt("请输入第一个数字"));
        var two = parseFloat(prompt("请输入第二个数字"));

        function cal(operation, one, two) {
            if (operation == '1') {
                return parseFloat(one) + parseFloat(two);
            }
            if (operation == "2") {
                return parseFloat(one) - parseFloat(two);
            }
            if (operation == "3") {
                return parseFloat(one) * parseFloat(two);
            }
            if (operation == "4") {
                return parseFloat(one) / parseFloat(two);
            }
        }
        alert('计算结果为' + cal(operation, one, two))
    </script>
</body>

</html>